package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.AttackDetectionAttrHandler;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.IpVersionHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @version V1.0
 * @author:lxb
 * @Package
 * @date:2021/4/15
 */
@Service
@AttrHandler(IpVersionHandler.class)
public class IpVersionAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {
    @Override
    public void handle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {
        KiteAttr attr31=kiteInst.getAttr("200002031");//IPV6掩码长度
        KiteAttr attr98=kiteInst.getAttr("10000198");//客户申请IPv4地址数量
        KiteAttr attr92=kiteInst.getAttr("10000992");//客户申请IPv6地址数量
        KiteAttr attr02=kiteInst.getAttr("2_0000202");//IPv4地址
        KiteAttr attr931=kiteInst.getAttr("10000931");//IPv6地址


        if(KiteStringUtils.equalsAny(kiteAttr.getValue(),"1","2")){
            attr31.setIsNull("F");
            attr92.setIsNull("F");
            attr931.setIsNull("F");
        }else {
            attr31.setIsNull("T");
            attr92.setIsNull("T");
            attr931.setIsNull("T");
        }
        if(KiteStringUtils.equalsAny(kiteAttr.getValue(),"0","2")){
            attr98.setIsNull("F");
            attr02.setIsNull("F");
        }else {
            attr98.setIsNull("T");
            attr02.setIsNull("T");
        }

    }

    @Override
    public void handleStyle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {

    }
}
